package EightQueens;

/**
 * 
 * @author Sebastian Brodehl, Dennis Meyer
 *
 */

public class Population {
	
	Individual[] population;
	
	public Population(int maxPopulationSize, boolean initialise)
	{
		this.population = new Individual[maxPopulationSize];
		
		if (initialise)
		{
			for (int i = 0; i < maxPopulationSize; i++) {
				this.population[i] = Individual.generateRandomIndividual();
			}
		}
	}
	
	public Individual getFittest()
	{
		Individual fittest = this.population[0];
		
		for (int i = 1; i < size(); i++) {
			fittest = fittest.getFitness() < this.population[i].getFitness() 
					? this.population[i] 
					: fittest;
		}
		
		return fittest;
	}
	
	public int size()
	{
		return this.population.length;
	}
}
